<template>
  <div class="home">
    <div class="home-left">
      <div class="user">
        <div class="image">
          <Icon type="ios-contact" />
        </div>
        <div class="user-name">张三</div>
        <div class="operation">
          <div class="button">编辑</div>
          <div class="button">退出</div>
        </div>
      </div>
      <div class="menus">
        <router-link
          :to="item.path"
          v-for="(item, index) in menus"
          :key="index"
          @click="changeMenu(index)"
        >
          <div class="menu" :class="{ selected: selectedIndex === index }">
            <div class="menu-icon">
              <Icon :type="item.icon" />
            </div>
            <div class="menu-name">{{ item.name }}</div>
          </div>
        </router-link>
      </div>
    </div>
    <div class="home-right">
      <div class="title">
        <div class="title-left">
          <div class="path">
            当前位置：{{ this.$router.currentRoute._value.name }}
          </div>
        </div>
        <div class="title-right">
          <div class="system-name">实验室冰箱管理系统</div>
        </div>
      </div>
      <div class="content">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "HomeView",
  components: {},
  data() {
    return {
      menus: [
        { name: "用户管理", icon: "ios-contact-outline", path: "/user" },
        { name: "角色管理", icon: "ios-contacts", path: "/role" },
        { name: "菜单管理", icon: "ios-list", path: "/menu" },
        { name: "字典管理", icon: "ios-book-outline", path: "/dictionary" },
      ],
      selectedIndex: 0,
      selected: "selected",
    };
  },
  methods: {
    changeMenu(index) {
      this.selectedIndex = index;
    },
  },
};
</script>

<style lang="less" scoped>
.home {
  display: flex;
  flex-direction: row;
  height: 100%;

  .home-left {
    height: 100%;
    display: flex;
    flex-direction: column;
    width: 10rem;

    .user {
      height: 10rem;
      background: #42b983;
      display: flex;
      flex-direction: column;

      .image {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 6rem;
      }

      .user-name {
        color: blueviolet;
      }

      .operation {
        display: flex;
        flex-direction: row;
        justify-content: center;

        .button {
          width: 3rem;
          font-size: 1rem;
          height: 2rem;
          line-height: 2rem;
        }
      }
    }

    .menus {
      border-top: dashed 1px #f1f1f1;
      flex: 1;
      padding-top: 0.5rem;
      background: #42b983;
      display: flex;
      flex-direction: column;

      .menu {
        height: 2.4rem;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        color: #222222;

        &:hover {
          color: blueviolet;
          cursor: pointer;
        }

        .menu-icon {
          font-size: 1.6rem;
          display: flex;
          justify-content: center;
          align-items: center;
        }

        .menu-name {
          margin-left: 0.2rem;
          font-size: 1.1rem;
        }

        &.selected {
          color: blueviolet;
          background: #f1f1f1;
        }
      }
    }
  }

  .home-right {
    //margin-left: 0.2rem;
    flex: 1;
    background: #f1f1f1;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    .title {
      width: 100%;
      display: flex;
      flex-direction: row;
      font-size: 1rem;

      .title-left {
        flex: 1;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
      }

      .title-right {
        width: 16rem;
        display: flex;
        flex-direction: row;
        justify-content: flex-end;

        .system-name {
          font-size: 1.4rem;
        }
      }
    }

    .content {
      flex: 1;
      width: 100%;
    }
  }
}
</style>
